package database

import (
	"abdis/interface/redis"
	"time"
)

type DbConsumer func(key string, entity *DataEntity, expireAt *time.Time) bool

type DB interface {
	Exec(client redis.Connection, cmdLine [][]byte) redis.Reply
	Close() error
	AfterClientClose(conn redis.Connection)
	ForEach(index int, consumer DbConsumer)
}

// KeyEventCallback will be called back on key event, such as key inserted or deleted
// may be called concurrently
type KeyEventCallback func(dbIndex int, key string, entity *DataEntity)

// DataEntity stores data bound to a key, including a string, list, hash, set and so on
type DataEntity struct {
	Data any
}

// CmdLine is alias for [][]byte, represents a command line
type CmdLine = [][]byte
